package com.springbootnetty.controller;


import com.springbootnetty.entity.TbGps;
import com.springbootnetty.mapper.TbGpsMapper;
import com.springbootnetty.netty_server.MyNettyServer;
import com.springbootnetty.result.CommonResult;
import com.springbootnetty.vo.TbGpsVo;
import com.springbootnetty.web_socket.WebSocketServer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@Api(tags = "Gps接口")
@RestController
@RequestMapping("/gps")
public class GpsController {


    @Resource
    TbGpsMapper tbGpsMapper;

    @ApiOperation("获取gps集合")
    @GetMapping("/getGps")
    private CommonResult<List<TbGpsVo>> getGps(@RequestParam(value = "msgPhone") String msgPhone, @RequestParam(value = "date") String date ) {
        List<TbGpsVo> gpsList = tbGpsMapper.selectListByDate(msgPhone,date);
        System.out.println(msgPhone);
        System.out.println(date);
        return CommonResult.success(gpsList);
    }

//    @ApiOperation("DO控制")
//    @PostMapping("/setDo")
//    private String setDo(@RequestBody DoDto doDto) {
//        for (int i = 0; i < doDto.getIndexList().size(); i++) {
//            Integer index = doDto.getIndexList().get(i);
//            ByteBuf byteBuf = PooledByteBufAllocator.DEFAULT.directBuffer();//声明一个bytebuf 对象
//            byte[] data ="ok".getBytes();
//            byteBuf.writeBytes(data);//获取字节数组
//            if (null != MyNettyServer.map.get(doDto.getIp())) {
//                MyNettyServer.map.get(doDto.getIp()).channel().writeAndFlush(byteBuf);
//            } else {
//                return "设备不在线";
//            }
//        }
//        return "下发命令成功";
//    }



}
